#include <stdio.h>
#include <stdlib.h>

//https://www.nowcoder.com/practice/7bbcdd2177a445a9b66da79512b32dd7?tpId=290&tags=&title=&difficulty=0&judgeStatus=0&rp=0&sourceUrl=%2Fexam%2Foj%2Fta%3FtpId%3D290

typedef struct Arr {
    int n;
    int arr[0];
}Arr;

void MoveForward(int *arr, int len) {
    arr[0] = arr[1];
    if (len > 1) {
        MoveForward(arr + 1, len - 1);
    }
};

int Delete(int *arr, int len, int num) {
    if (*arr == num) {
        MoveForward(arr, len);
        return Delete(arr, len - 1, num);
    } else if (len) {
        return 1 + Delete(arr + 1, len - 1, num);
    }
    return 0;
}

int main() {
    int num = 0;
    int len = 0;
    Arr *arr = (Arr *) malloc(sizeof(Arr) + len * sizeof(int));
    scanf("%d", &len);
    for (int i = 0; i < len; i++) {
        scanf("%d", &arr->arr[i]);
    }
    scanf("%d", &num);
    len = Delete(arr->arr, len, num);
    for (int i = 0; i < len; i++) {
        printf("%d ", arr->arr[i]);
    }
    return 0;
}